package com.td.module.member.dal.mysql.appMemberUser;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.td.framework.common.pojo.PageResult;
import com.td.framework.mybatis.core.mapper.BaseMapperX;
import com.td.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.td.module.member.controller.admin.appMemberUser.vo.AppMemberUserExportReqVO;
import com.td.module.member.controller.admin.appMemberUser.vo.AppMemberUserPageReqVO;
import com.td.module.member.dal.dataobject.appMemberUser.AppMemberUserDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * app用户 Mapper
 *
 * @author 王翔翔
 */
@Mapper
public interface AppMemberUserMapper extends BaseMapperX<AppMemberUserDO> {

    default PageResult<AppMemberUserDO> selectPage(AppMemberUserPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<AppMemberUserDO>()
                .likeIfPresent(AppMemberUserDO::getNickname, reqVO.getNickname())
                .eqIfPresent(AppMemberUserDO::getType, reqVO.getType())
                .eqIfPresent(AppMemberUserDO::getStatus, reqVO.getStatus())
                .eqIfPresent(AppMemberUserDO::getMobile, reqVO.getMobile())
                .betweenIfPresent(AppMemberUserDO::getLoginDate, reqVO.getLoginDate())
                .eqIfPresent(AppMemberUserDO::getIsAuth, reqVO.getIsAuth())
                .betweenIfPresent(AppMemberUserDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(AppMemberUserDO::getId));
    }

    default List<AppMemberUserDO> selectList(AppMemberUserExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<AppMemberUserDO>()
                .likeIfPresent(AppMemberUserDO::getNickname, reqVO.getNickname())
                .eqIfPresent(AppMemberUserDO::getType, reqVO.getType())
                .eqIfPresent(AppMemberUserDO::getStatus, reqVO.getStatus())
                .eqIfPresent(AppMemberUserDO::getMobile, reqVO.getMobile())
                .betweenIfPresent(AppMemberUserDO::getLoginDate, reqVO.getLoginDate())
                .eqIfPresent(AppMemberUserDO::getIsAuth, reqVO.getIsAuth())
                .betweenIfPresent(AppMemberUserDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(AppMemberUserDO::getId));
    }

    default AppMemberUserDO selectByMobile(String mobile) {
        return selectOne(new LambdaQueryWrapper<AppMemberUserDO>().eq(AppMemberUserDO::getMobile, mobile));
    }
}
